home *** CD-ROM | disk | FTP | other *** search
/ Power Tools for Macintosh / Power Tools for Macintosh (SoftBit)(1992).iso / Applications / DiskWorld / Text files / Pascal docs < prev    next >
Text File  |  1989-11-10  |  7KB  |  55 lines

  1. •••  “Blaise-ing” along •••
  2.  
  3. We have been getting a lot of mail lately with questions about Pascal.  Most of them have been along the lines of “What is a ‘Pascal’ and why would I want to have one on my Macintosh?”  I suppose there are people who have given thought to programming the Macintosh and don’t know why they should choose one development environment over another.  This month I will look at several ways to program the Macintosh, trying to give the best (and worst) reasons for choosing whether or not to pick a particular system.  
  4.  
  5. •••   Hypercard   ••• 
  6. Yes, there is a programming language buried in there somewhere.  It is called Hypertalk, and it is powerful. 
  7.  
  8. •  Strengths - Hypercard has excellent graphic tools, easy manipulation of buttons, menus, and other “objects,” and an absolutely fantastic metaphor to work from.  Stacks of “cards” with buttons for navigation are great for developing specific types of software - most notably educational software.  Hypercard has also found a firm niche in the development community as a “prototyper” system for trying out new ideas before committing major resources to a programming project.
  9.  
  10. •  Weaknesses - Hypercard severely limits available work space.  Cards are only allowed to be the size of the standard Macintosh screen.  Hypercard does not support color.  Certain input limitations are very frustrating to programmers, and last but certainly not the least, Hypercard is slow.  As an interpreted language, Hypercard is one of the slowest ways to get a problem solved.  If speed is important to you, Hypercard will not suit your needs.
  11.  
  12. •••   BASIC   •••
  13. “Beginners All-purpose Symbolic Instruction Code” is a great place for beginners to start programming.  
  14.  
  15. •  Strengths - BASIC is an easy to learn language, with most commands in an English-like syntax that anyone should be familiar with in a short time.  Because BASIC is so commonly used on other computers there are literally thousands of examples of how to solve particular problems.  BASIC is usually interpreted (executed one line of code at a time by a “driving program”) which is, in a word, slow.  However, BASIC compilers (compiled programs are converted into “machine code” when they are created, this allows them to run much faster) are becoming more common and the speed problems that plagued early BASIC programs are becoming a thing of the past.  BASIC usually supports powerful mathematical features, sometimes including sophisticated financial and algebraic functions that could save a programmer days or weeks of coding.
  16.  
  17. •  Weaknesses - As noted above, BASIC is commonly interpreted and therefore slow.  Many of the BASIC systems that are compiled require large “drivers” or modules of code that are lumped together with your code whether you need all the code in the driver or not.  In simple terms, BASIC programs tend to be very large, on the order of at least 75K for a chore that could have been accomplished in as little as 10 or 15K of Assembly language.  Because of this large overhead, BASIC compilers also tend to be rather slow when compared to other compilers.
  18.  
  19. •••   Assembly Language   •••
  20. “Real programmers use assembly language.”  Assembly language is a method of coding your program on a one-to-one basis with the CPU inside the computer.  For example, adding two numbers in Assembler could be done like this:
  21.  
  22.    Move “5” into register 1.
  23.    Add “6” to register 1.   {Register 1 would now hold {“11”}
  24.    Move register 1 to the memory address stored in register 3.
  25.    etc....
  26. You get the idea.
  27.    
  28.  
  29. •  Strengths - Too numerous to mention.  Without a doubt all code should be written in hand-coded assembler to optimize all aspects of the hardware.  Of course this is impossible because of the:
  30.  
  31. •  Weaknesses - Which are also too numerous to mention.  If all code were written in assembler, we would have very little code written at all.  Assembly language is not for the weak of heart.  Most enlightened programmers will use a conventional “high-level” language to write their programs, and then use assembly language routines to “optimize” any code bottlenecks that are slowing things down.  
  32.  
  33. •••   C   •••
  34. “Almost real programmers use C.”
  35.  
  36. •  Strengths - C is a very powerful language with most of the power of Assembly language.  One way of ranking the power of a programming language is to compare the smallest level of memory access a language gives you.  C is a “bit-level-access” language, meaning you can actually fiddle around with individual bits in the computer’s memory.  C code compiles well (small, that is) and development time is much shorter than with assembly language.
  37.  
  38. •  Weaknesses - C is a confusing language, and it is powerful enough to really get yourself into trouble.  Error checking is minimal, and debugging C code has been known to drive grown men to their knees.  Of course a good debugging package will help in this area.  C is not something you will pick up over a weekend.  Plan on taking a few college-level courses before you can really make full use of this language.
  39.  
  40. •••   Pascal   •••
  41. Pascal was designed as a “teaching” language.  The original Pascal language was weak in several areas, but it had some important strengths.  Modern day versions of Pascal are streamlined and full-featured.  The Macintosh is very much a “Pascal machine” since the ROM was written in Pascal format.  
  42.  
  43. •  Strengths - Pascal compilers are very fast, and Pascal code is relatively easy to read.  Since it was originally designed to be taught, Pascal is one of the easiest higher-level languages to learn.  Modular programming is strongly encouraged in Pascal.  Error-checking is handled well in Pascal, and debugging is much easier than in Assembly or C.
  44.  
  45. •  Weaknesses - Believe it or not, the chief problem with Pascal is the error-checking.  Pascal performs a “type-casting” method of designating variables.  An integer in Pascal is not necessarily an integer.  It could be a “pointer,” for example.  Although an integer and a pointer are identical in computer memory, they are not the same to a Pascal program.  This was designed purposefully as a way to force programmers to keep track of variables.  It works.  Pascal programmers have been observed running down the street shouting “It’s an INTEGER!  An INTEGER!” while tearing out their hair.
  46.  
  47. ••••   The bottom line   ••••
  48.  
  49. So what is the best package to use?  For beginners, Hypercard and BASIC are both highly recommended.  The major weaknesses of Hypercard can be handled well in BASIC, but Hypercard has an advantage in graphics and in the interface that is already built in.
  50.  
  51. For serious development, because the Macintosh was designed in Pascal, I would have to give Pascal the edge.  C is similar enough to Pascal to come in a close second.  I would have leaned more toward C if not for the inescapable fact that the entire five-volume set of Inside Macintosh (which is absolutely necessary for any serious development) is written for Pascal (with a little Assembly language thrown in).  Support for Pascal programmers is much better, and Pascal is simply easier to learn for beginners.
  52.  
  53. Of course that is why we have this monthly feature.  The MAChanic will continue next month with more samples of how to program your Mac in Pascal.  See ya’ll then
  54.          ---Sean Golden
  55.